<?php
/***
 *创作打印图制作队列
 *
 *
 * @author    lanhongjie <lanhj@yunys.com.cn>
 * @copyright 2016 QuanZhouYunYiShang Inc.
 */
namespace App\Jobs;

use App\Services\PrintService\PrintService;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Log;

class Php2PyImg implements ShouldQueue
{
    use InteractsWithQueue, Queueable, SerializesModels;
    protected $img_data;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(array $img_data)
    {
        $this->img_data=$img_data;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        try{
            $img_data=$this->img_data;
            $printService=new PrintService();
            Log::info('*************** 调取 job2py ******************');
            @$res=$printService->job2py($img_data);
            return true;
        }catch (\Exception $e){
            Log::info(date("Y-m-d h:i:s", time()));
            Log::info('*********** Php2Py handle 异常 **************');
            Log::info($e);
            return false;
        }
    }
}
